﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSNPro.Base;

namespace TSNPro.Communication
{
    public class BaseCommunication : BaseItem
    {
        private string _communicationParam;

        public BaseCommunication() : base()
        {
        }

        public void SetCommunicationParam(string communicationParam)
        {
            _communicationParam = communicationParam;
        }

        public string GetCommParam()
        {
            return _obj["Address"].ToString();
        }

        public virtual bool ConnectToHost()
        {
            // Your connection logic here
            return true;
        }

        public virtual bool IsConnected()
        {
            // Your connection check logic here
            return true;
        }

        public virtual bool DisConnectFromHost()
        {
            // Your disconnection logic here
            return true;
        }

        public override Control GetConfigWidget()
        {
            // In C#, we use a Form or a custom window for dialog-like functionality
            var dialog = new Form();  // You can use any specific form or control here
            return dialog;
        }

        public override void SetConfig(JObject obj)
        {
            base.SetConfig(obj);
        }

        public override bool Init()
        {
            return ConnectToHost();
        }
    }
}
